home *** CD-ROM | disk | FTP | other *** search
/ Computer Inter@ctive 17 / Computer Interactive cdrom 17 - gen 99.iso / ZDNETIT / CONTENT / OPTIVDOS.ZIP / INCLUDE.ZIP / VULSTD.H < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-21  |  7.1 KB  |  179 lines

  1. /*  VULstd.h
  2.  
  3.   vector management functions for data type "unsigned long".
  4.  
  5.   Copyright (c) 1996-1998 by Martin Sander
  6.   All Rights Reserved.
  7. */
  8.  
  9. #ifndef __VULSTD_H
  10. #define __VULSTD_H
  11.  
  12. #if !defined( __VECLIB_H )
  13.    #include <VecLib.h>
  14. #endif
  15.  
  16. #ifdef __cplusplus
  17.     extern "C" {
  18. #endif
  19.  
  20. /*****************************  Generation ******************************/
  21.  
  22. ulVector  __vf  VUL_vector( ui size );
  23. ulVector  __vf  VUL_vector0( ui size );
  24.  
  25. /***************  Addressing single vector elements ******************/
  26.  
  27. unsigned long _VFAR * VUL_Pelement( ulVector X, ui n );
  28.       /* returns a pointer to the n'th element of X. For the memory model
  29.          HUGE, the pointer is normalized. */
  30. #define VUL_element( X, n ) (*VUL_Pelement( X, n ))
  31.  
  32. /****************** Initialization  ******************************/
  33.  
  34. void  __vf  VUL_equ0( ulVector X, ui size );
  35. void  __vf  VUL_equC( ulVector X, ui size, unsigned long C );
  36. void  __vf  VUL_equV( ulVector Y, ulVector X, ui size );
  37. void  __vf  VULo_ramp( ulVector X, ui size, unsigned long Start, long Rise );
  38. #ifdef V_trapIntError
  39.     #define VUL_ramp    VULo_ramp
  40. #else
  41.     void __vf  VUL_ramp( ulVector X, ui size, unsigned long Start, long Rise );
  42. #endif
  43. long  __vf  VUL_random( ulVector X, ui size, long seed,
  44.                         unsigned long MinVal, unsigned long MaxVal );
  45.                               /*  returns new seed */
  46.  
  47. /**************  Data-type interconversions  **************************/
  48.  
  49. void __vf  Vo_LItoUL( ulVector Y, liVector X, ui size );  /* signed-unsigned */
  50. void __vf  Vo_ULtoLI( liVector Y, ulVector X, ui size );
  51.  
  52. void __vf  V_UStoUL( ulVector Y, usVector X, ui size );  /* up-conversion */
  53. void __vf  V_UtoUL(  ulVector Y, uVector  X, ui size );
  54.  
  55. void __vf  Vo_ULtoUS( usVector Y, ulVector X, ui size ); /* down-conversion */
  56. void __vf  Vo_ULtoU(  uVector  Y, ulVector X, ui size );
  57. #ifdef V_trapIntError
  58.     #define V_LItoUL    Vo_LItoUL
  59.     #define V_ULtoLI    Vo_ULtoLI
  60.     #define V_ULtoUS    Vo_ULtoUS
  61.     #define V_ULtoU     Vo_ULtoU
  62. #else
  63.     void  __vf   V_LItoUL( ulVector Y, liVector X, ui size );
  64.     void  __vf   V_ULtoLI( liVector Y, ulVector X, ui size );
  65.     void  __vf   V_ULtoUS( usVector Y, ulVector X, ui size );
  66.     void  __vf   V_ULtoU(  uVector  Y, ulVector X, ui size );
  67. #endif
  68.  
  69. void  __vf   V_ULtoF(  fVector Y, ulVector X, ui size );
  70. void  __vf   V_ULtoD(  dVector Y, ulVector X, ui size );
  71. #ifdef __BORLANDC__
  72.     void  __vf   V_ULtoE(  eVector Y, ulVector X, ui size );
  73. #else  /* no 80-bit IEEE reals with Visual C++ */
  74.     #define V_ULtoE V_ULtoD
  75. #endif
  76.  
  77.  
  78. /************** Index-oriented manipulations ***************************/
  79.  
  80. void  __vf  VUL_rev( ulVector Y, ulVector X, ui size );
  81. #ifdef V_HUGE
  82.     void  __vf  VUL_rotate( ulVector Y, ulVector X, ui size, long pos );
  83. #else
  84.     void  __vf  VUL_rotate( ulVector Y, ulVector X, ui size, int pos );
  85. #endif
  86.  
  87. void  __vf  VUL_delete( ulVector X, ui size, ui pos );
  88. void  __vf  VUL_insert( ulVector X, ui size, ui pos, unsigned long C );
  89.  
  90. void  __vf  VUL_sort( ulVector Y, ulVector X, ui size, int dir );
  91. void  __vf  VUL_sortind( uiVector Ind, ulVector X, ui size, int dir );
  92.  
  93. void  __vf  VUL_subvector( ulVector Y, ui sizey, ulVector X, int samp );
  94. void  __vf  VUL_subvector_equC( ulVector Y, ui subsz, unsigned samp,
  95.                                 unsigned long C );
  96. void  __vf  VUL_subvector_equV( ulVector Y, ui subsz, unsigned samp,
  97.                                 ulVector X );
  98.  
  99. void  __vf  VUL_indpick( ulVector Y, uiVector Ind, ui sizey, ulVector X );
  100. void  __vf  VUL_indput(  ulVector Y, ulVector X, uiVector Ind, ui sizex );
  101.  
  102. ui    __vf  VUL_searchC( ulVector XTab, ui size, unsigned long C, int mode );
  103. void  __vf  VUL_searchV( uiVector Ind, ulVector X, ui sizex,
  104.                          ulVector Tab, ui sizetab, int mode );
  105.  
  106. /********************   One-dimensional Vector Operations  ********/
  107.  
  108. unsigned long  __vf  VULo_sum( ulVector X, ui size );
  109. void           __vf  VULo_runsum( ulVector Y, ulVector X, ui size );
  110. #ifdef V_trapIntError
  111.     #define VUL_sum       VULo_sum
  112.     #define VUL_runsum    VULo_runsum
  113. #else
  114.     unsigned long  __vf  VUL_sum( ulVector X, ui size );
  115.     void           __vf  VUL_runsum( ulVector Y, ulVector X, ui size );
  116. #endif
  117. unsigned long  __vf  VUL_max( ulVector X, ui size );
  118. unsigned long  __vf  VUL_min( ulVector X, ui size );
  119. unsigned long  __vf  VUL_maxind( ui _VFAR *Ind, ulVector X, ui size );
  120. unsigned long  __vf  VUL_minind( ui _VFAR *Ind, ulVector X, ui size );
  121. double         __vf  VUL_fsum( ulVector X, ui size );
  122. double         __vf  VUL_mean( ulVector X, ui size );
  123. void   __vf  VUL_runmax( ulVector Y, ulVector X, ui size );
  124. void   __vf  VUL_runmin( ulVector Y, ulVector X, ui size );
  125.  
  126. int    __vf  VUL_iselementC( ulVector Tab, ui size, unsigned long  C );
  127. ui     __vf  VUL_iselementV( ulVector Y, ulVector X, ui sizex,
  128.                              ulVector Tab, ui sizetab );
  129.  
  130.  
  131. /************************ Input / Output ******************************/
  132.  
  133. void  __vf   V_ifprint(  FILE _VFAR *stream, void _VFAR *X, ui size,
  134.                   unsigned nperline, unsigned linewidth, unsigned vers );
  135. #define VUL_fprint( st, x, sz, npl, lw ) \
  136.              V_ifprint(  st, (void _VFAR *)(x), sz, npl, lw, 7 )
  137.  
  138. #if !(defined _Windows || defined _WINDOWS)
  139.    void __vf  V_icprint(  void _VFAR *X, ui size, unsigned nperline, unsigned vers );
  140.    #define VUL_cprint( x, sz, npl ) V_icprint( (void _VFAR *) (x), sz, npl, 7 )
  141. #endif
  142. #define VUL_print( x, sz, npl ) \
  143.              V_ifprint(  stdout, (void _VFAR *)(x), sz, npl, 80, 7 )
  144.  
  145. void  __vf   V_setRadix( int radix );
  146.            /* radix to be assumed by all whole-number read functions V??_read */
  147. void  __vf   VUL_read( ulVector X, ui size, FILE _VFAR *stream );
  148. void  __vf   VUL_write( FILE _VFAR *stream, ulVector X, ui size );
  149. void  __vf   VUL_nread( unsigned n, ui size, FILE _VFAR *stream, ... );
  150. void  __vf   VUL_nwrite( FILE _VFAR *stream, unsigned n, ui size, ... );
  151. void  __vf   VUL_setWriteFormat( char _VFAR *FormatString );
  152.                                             /* for VUL_write and VUL_nwrite */
  153. void  __vf   VUL_setWriteSeparate( char _VFAR *SepString ); /* for VUL_write */
  154. void  __vf   VUL_setNWriteSeparate( char _VFAR *SepString ); /* for VUL_nwrite */
  155. #ifdef V_HUGE
  156.     void  __vf   VUL_store(  FILE _VFAR *stream, ulVector X, ui size );
  157.     void  __vf   VUL_recall( ulVector X, ui size, FILE _VFAR *stream );
  158. #else
  159.     #ifdef __cplusplus
  160.          void  inline VUL_store( FILE _VFAR *stream, ulVector X, ui size )
  161.          {    fwrite( X, sizeof(unsigned long), size, stream ); 
  162.          }
  163.          void  inline VUL_recall( ulVector X, ui size, FILE _VFAR *stream )
  164.          {    fread(  X, sizeof(unsigned long), size, stream );
  165.          }
  166.     #else
  167.         #define VUL_store( str, X, sz )  \
  168.                      fwrite( X, sizeof(unsigned long), sz, str )
  169.         #define VUL_recall( X, sz, str ) \
  170.                      fread(  X, sizeof(unsigned long), sz, str )
  171.     #endif
  172. #endif      /* VUL_store, VUL_recall in binary format */
  173.  
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177.  
  178. #endif   /*  __VULSTD_H    */
  179.